package g4p.newg4p;

import g4p_controls.GAlign;
import g4p_controls.GEvent;
import g4p_controls.GImageButton;
import g4p_controls.GLabel;
import processing.core.PApplet;

public class ImageButton_Test extends PApplet {

	
	GImageButton btnGhost, btnCoins, btnTJ, btnInfo;
	GLabel lblOut;
	long timer;
	String[] files;

	public void setup() {
	  size(580, 220);
	  cursor(CROSS);
	  String[] files;

	  files = new String[] { 
	    "g4p/infooff.png", "g4p/infoover.png", "g4p/infodown.png"
	  };
	  btnInfo = new GImageButton(this, 20, 14, files, "g4p/infomask.png");

	  files = new String[] { 
	    "g4p/ghost0.png", "g4p/ghost1.png", "g4p/ghost2.png"
	  };
	  btnGhost = new GImageButton(this, 40, 90, files);

	  files = new String[] { 
	    "g4p/tjoff.jpg", "g4p/tjover.jpg", "g4p/tjdown.jpg"
	  };
	  btnTJ = new GImageButton(this, 150, 10, files, "g4p/tjmask.png");
//	  btnTJ = new GImageButton(this, 150, 10, 250,100, files, "tjmask.png");

	  files = new String[] { 
	    "g4p/coins0.png", "g4p/coins1.png", "g4p/coins2.png"
	  };
	  btnCoins = new GImageButton(this, 400, 20, files);

	  lblOut = new GLabel(this, 10, 190, 560, 20, "");
	  lblOut.setTextAlign(GAlign.CENTER, null);
	  timer = millis() - 5000;
	}

	public void draw() {
	  background(220, 220, 255);
	  if (millis() - timer > 4000) {
	    lblOut.setText("CLICK ON A BUTTON");
	  }
	}

	//btnGhost, btnCoins, btnTJ, btnInfo;

	void handleButtonEvents(GImageButton button, GEvent event) {
	  if (button == btnGhost)
	    lblOut.setText("Ghosts - composite image using transparency");
	  else if (button == btnCoins)
	    lblOut.setText("Coins - composite image using transparency");  
	  else if (button == btnTJ)
	    lblOut.setText("Tom & Jerry - multiple images using mask");
	  else if (button == btnInfo)
	    lblOut.setText("Info - multiple images using mask");
	  timer = millis();
	}


}
